package pe.com.hermes.hermetic.modelo.daoimpl;

import com.ibatis.sqlmap.client.SqlMapClient;

import pe.com.hermes.hermetic.beans.FavoritosBean;
import pe.com.hermes.hermetic.modelo.dao.FavoritosDAO;
import pe.com.hermes.hermetic.negocio.ultil.CadenaUtil;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import oracle.jdbc.OracleTypes;

import org.apache.log4j.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.CallableStatementCallback;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

@Repository("favoritosDAO")
public class FavoritosDAOImpl implements FavoritosDAO {
    @Autowired
    protected JdbcTemplate jdbcTemplate;
    private Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private SqlMapClient sqlMapClient;    

  public List buscarFavoritos(final String usuario, 
                            final int razonSocial){
  
     Map map = new HashMap();
     map.put("P_USU_WEB",usuario);
     map.put("P_RAZO_SOC_USU",razonSocial);
     List listFavoritos=new ArrayList();
     int erro = 0;
     try{
         sqlMapClient.queryForObject("buscarFavorito",map);
         erro=(Integer)map.get("S_ERRO");
         if(erro==0)
             listFavoritos = (List)map.get("S_LIST");
         else
             throw new Exception((String)map.get("S_MENS"));
     }catch(Exception e){
         logger.error(e);
         e.printStackTrace();
         listFavoritos = new ArrayList();
     }
     return listFavoritos;
                           }

}